home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
c_lang
/
varinc.lzh
/
PAGE232.C
< prev
next >
Wrap
Text File
|
1979-11-30
|
683b
|
27 lines
#define NCOLS 3
/* Sum rows of an n-row, 3-column array of short integers. */
main()
{
static short matrix[][NCOLS] = {0, 1, 2,
3, 4, 5);
short nrows = 2;
show_sums(matrix, nrows);
}
show_sums(matrix, nrows)
short matrix[][NCOLS]; /* array of rows to sum */
short nrows; /* number of rows to sum */
{
short irow, icol, sum;
for (irow = 0; irow < nrows; ++irow)
{
for (sum = icol = 0; icol < NCOLS; ++icol)
sum += matrix[irow][icol];
printf("Sum of row %d is %d.\n", irow, sum);
}
}